package com.sc.nft.service.impl;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.dao.UserEcologyCastUpperLimitDetailsDao;
import com.sc.nft.dao.UserEcologyHatchUpperLimitDetailsDao;
import com.sc.nft.dto.EcologyHatchConfDao;
import com.sc.nft.entity.EcologyCastConf;
import com.sc.nft.entity.EcologyHatchConf;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.vo.ecology.UserEcologyCastUpperLimitDetailsVO;
import com.sc.nft.entity.vo.ecology.UserEcologyHatchUpperLimitDetailsVO;
import com.sc.nft.exception.GlobalRunTimeException;
import com.sc.nft.service.UserEcologyHatchUpperLimitDetailsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author 朱梦晨
 * @Description:
 * @date 2024-08-06
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class UserEcologyHatchUpperLimitDetailsServiceImpl implements UserEcologyHatchUpperLimitDetailsService {

    private final EcologyHatchConfDao ecologyHatchConfDao;

    private final UserEcologyHatchUpperLimitDetailsDao userEcologyHatchUpperLimitDetailsDao;

    @Override
    public Page<UserEcologyHatchUpperLimitDetailsVO> userEcologyHatchUpperLimitDetails(UserInfo user, Long id, Integer pageNo, Integer pageSize) {
        EcologyHatchConf ecologyHatchConf = ecologyHatchConfDao.getById(id);
        Assert.notNull(ecologyHatchConf, () -> new GlobalRunTimeException("生态熔炼不存在"));

        return userEcologyHatchUpperLimitDetailsDao.getUserEcologyHatchUpperLimitDetails(user.getId(), ecologyHatchConf.getCollectionId(), pageNo, pageSize);
    }

}
